Skip to content

[CodeQuality] Add failing fixture crash on deep ArrayItem as Foreach_ value on DirectInstanceOverMockArgRector#632

Merged
samsonasik merged 2 commits intomainfrom
add-failing
Feb 3, 2026
Merged

[CodeQuality] Add failing fixture crash on deep ArrayItem as Foreach_ value on DirectInstanceOverMockArgRector#632
samsonasik merged 2 commits intomainfrom
add-failing

Conversation

@samsonasik
Copy link
Member

@samsonasik samsonasik commented Feb 3, 2026

Given the following code:

    public function testThat()
    {
        $regex = '/(?P<version>\d+\.\d+\.\d+)/';
        $contents = 'VERSION: 1.0.0';
        $operations = [];

        if (preg_match_all($regex, $contents, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER) > 0) {
            foreach ($matches as ['version' => [$fullVersion, $offset]]) {
                $operations[] = [$fullVersion, $offset];
            }
        }
    }

it got crash:

There was 1 error:

1) Rector\PHPUnit\Tests\CodeQuality\Rector\CallLike\DirectInstanceOverMockArgRector\DirectInstanceOverMockArgRectorTest::test with data set #4 ('/Users/samsonasik/www/rector-...hp.inc')
Rector\Exception\ShouldNotHappenException: Scope not available on "PhpParser\Node\ArrayItem" node. Fix scope refresh on changed nodes first

/Users/samsonasik/www/rector-phpunit/vendor/rector/rector-src/src/PHPStan/ScopeFetcher.php:26
/Users/samsonasik/www/rector-phpunit/rules/CodeQuality/Rector/CallLike/DirectInstanceOverMockArgRector.php:91

Ref rectorphp/rector#9628
see https://getrector.com/demo/da6425e5-7a8e-44ff-ac74-b1c0b478695e

@samsonasik
Copy link
Member Author

@samsonasik
Copy link
Member Author

I've pushed empty commit 091756b to trigger fetch latest rector-src patch here

@samsonasik
Copy link
Member Author

All green now 🎉 @TomasVotruba let's merge ;)

@samsonasik samsonasik merged commit bc79241 into main Feb 3, 2026
7 checks passed
@samsonasik samsonasik deleted the add-failing branch February 3, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant